<!--  -->
<template>
	<view class="asset">
		<view class="head">
			<view class="left">
				<view class="img"> <image src="/static/home/bian@2x.png" class="icon" mode=""></image> </view>
					<picker mode="selector" :range="marketArr" range-key="name" @change="changePicker"
					class="picker-box">
					<text class="market-name">{{market}}</text>
					<u-icon name="arrow-down" class="arrow" size="22" color="#C9C9C9"></u-icon>
				</picker>
			</view>
			<view>
				<image src="/static/home/home_share@2x.png" class="icon2" mode="" @click="onAppShare"></image>
			</view>

		</view>
		<view class="list">
			<view class="item">
				<view class="item-title start">总资产折合(USDT)</view>
				<view class="item-content">
					<text class="amount start">2000</text>
				</view>
			</view>
			<view class="item">
				<view class="item-title end">累计收益（￥）</view>
				<view class="item-content end">
					<text class="amount blue">32000</text>
				</view>
			</view>
		</view>
		<view  class="u-line line">
			<u-line color="#E4E4E4"/>
		</view>
		

		<view class="list">
			<view class="item">
				<view class="item-title start">
					<text>运行中策略</text>
				</view>
				<view class="item-content start">
					<text>3</text>
				</view>
			</view>

			<view class="item">
				<view class="item-title center">
					<text>今日利润</text>
				</view>
				<view class="item-content center">
					<text>42677</text>
				</view>
			</view>

			<view class="item">
				<view class="item-title end">
					<text>预估年化</text>
				</view>
				<view class="item-content end">
					<text>30%</text>
				</view>
			</view>
		</view>

		<view class='hidden' v-show="true">
       <uqrcode ref="uqrcode"></uqrcode>
    </view>
	</view>
</template>

<script>
	import {
		appShare,
		closeAppShare
	} from '@/utils/shareutil';
	import {
		fakePosition,
	} from "@/api/mock/home.js";
	export default {
		onReady() {
      this.$refs
          .uqrcode
          .make({
              size: 120,
              text: 'http://yide.aqielife.cn'
          })
          .then(res => {
              // 返回的res与uni.canvasToTempFilePath返回一致
              console.log('生成二维码',res)
              this.promoteCodeImg = res.tempFilePath
          })
    },
		data() {
			return {
				market: '',
				marketArr: [],
				// 分享
				// 1.背景图片
      	promoteBgImgs: [
        	"http://yide.aqielife.cn/home_share.png",
      	],
     		 // 2.分享二维码图片
      	promoteCodeImg: "http://yide.aqielife.cn/wx.jpg",
				swiperIndex: 0,
      	posterImgs: [],
			};
		},

		components: {},

		computed: {},

		mounted() {
			fakePosition().then(data => {
				this.market = data.position;
				this.marketArr = data.positionArr;
			});
		},

		methods: {
			changePicker(e) {
				this.market = this.marketArr[e.detail.value];
			},
			// APP分享
			onAppShare() {
				// #ifdef APP-PLUS
				let shareData = {
					/* 
					shareImg: "http://yide.aqielife.cn/home_share.png", */
					type:2,
					shareUrl:"https://kemean.com/",
					shareTitle:"分享的标题1",
					shareContent:"分享的描述2",
					shareImg:"http://yide.aqielife.cn/home_share.png",
					// appId : "wxd0e0881530ee4444",
					// appPath : "pages/home/home",
					// appWebUrl : "https://kemean.com/",
				}
				console.log('shareData', shareData)
				let shareObj = appShare(shareData,
				res => {
					console.log("分享成功回调", res);
					// 分享成功后关闭弹窗
					// 第一种关闭弹窗的方式
					closeAppShare();
				});
				setTimeout(() => {
					// 第二种关闭弹窗的方式
					shareObj.close();
				}, 5000);
				// #endif
				// #ifndef APP-PLUS
				uni.showToast({
					title: "请在APP环境使用",
					icon: "none"
				});
				// #endif
			},

			//用户点击分享
			onShareAppMessage(e) {
				// wxShare方法已挂载全局
				return this.wxShare();
			}

		},
	};
</script>
<style lang='scss' scoped>
	.asset {
		.head {
			margin: 20rpx 30rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			.left {
				display: flex;
				.market-name{
					margin: 0 20rpx 0 10rpx;
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #333333;
				}
				.icon{
					width: 32rpx;
					height: 32rpx;
				}
			}
			.icon2 {
				width: 40rpx;
				height: 40rpx;
			}
		}
		.list {
			margin: 0 30rpx;
			background-color: #fff;
			// border: 1px solid green;
			display: flex;
			justify-content: space-between;
			width: 686rpx;
			height: 140rpx;
			padding: 15rpx 30rpx;
			border-radius: 12rpx;

			.item {
				display: flex;
				min-width: 200rpx;
				flex-direction: column;
				height: 100rpx;
				// border: 1px solid red;
				justify-content: space-around;
				align-items: center;

				&-title {
					display: flex;
					min-width: 200rpx;
					height: 26rpx;
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: 400;
					color: #666666;
					// border: 1px solid blue;
				}

				&-content {
					display: flex;
					min-width: 200rpx;
					height: 40rpx;
					font-size: 36rpx;
					font-family: DIN;
					font-weight: 550;
					color: #333333;
				}
				.start {
					justify-content: flex-start;
				}
				.end {
					justify-content: flex-end;
				}
				.center {
					justify-content: center;
				}
			}

		}
		.line {
			margin: 0 auto;
			width: 500rpx;
		}
		.blue {
			color: #1488FF
		}

	}
	.hidden {
		z-index: -999;
		position: absolute;
		width: 0;
		height: 0;
	}
</style>
